# ADMIN: Used to add/remove/edit teams

class Admin::TeamsController < Admin::BaseController
  def index
    @teams = Team
    @teams = @teams.scoped(:conditions=>{:alias_done=>false}) if params[:no_alias]
    @teams = @teams.paginate :page=>params[:page]
  end

  def edit
    @team = Team.find params[:id]
  end

  def update
    @team = Team.find params[:id]
    if @team.update_attributes params[:team]
      flash[:notice] = "update successful."
      redirect_to admin_teams_path
    else
      render :action=>"edit"
    end
  end

  def new
    @team = Team.new
  end
  
  def create
    @team = Team.new params[:team]
    if @team.save
      flash[:notice]='successful created.'
      redirect_to admin_teams_path
    else
      render :action=>'new'
    end
  end
  
  def destroy
    @team = Team.find params[:id]
    @team.destroy
    flash[:notice]='successful deleted.'
    redirect_to admin_teams_path
  end
  
end
